#include "databasemanager.h"

DatabaseManager &DatabaseManager::instance()
{
    static DatabaseManager instance;
    return instance;
}

DatabaseManager::DatabaseManager(QObject *parent)
    : QObject{parent}
{
    db=QSqlDatabase::addDatabase("QSQLITE");//add device
    if(!openDatabase(dbPath)){
        qFatal("failed to open database!!!");
    }else{
        qDebug()<<"open databse.";
    }
}

bool DatabaseManager::openDatabase(const QString &path)
{
    db.setDatabaseName(path);
    if(!db.open()){
        qDebug()<<"database is not open!!!";
        return false;
    }
    qDebug()<<"database is open";
    return true;
}

void DatabaseManager::closeDatabase()
{

}
